package yesjava;

import java.util.Objects;

public class Cat implements Comparable<Cat> {
    private String color;
    private int age;


    public int compareTo(Cat o) {
        return o.getAge() - this.getAge();
    }

    public Cat(String color, int age) {
        this.color = color;
        this.age = age;
    }

    public Cat() {
    }

    public String getColor() {
        return color;
    }

    public Cat setColor(String color) {
        this.color = color;
        return this;
    }

    public int getAge() {
        return age;
    }

    public Cat setAge(int age) {
        this.age = age;
        return this;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cat cat = (Cat) o;
        return Objects.equals(color, cat.color);
    }

    @Override
    public int hashCode() {
        return  Objects.hash(color);
    }

    @Override
    public String toString() {
        return "Cat{" +
                "color='" + color + '\'' +
                ", age=" + age +
                '}';
    }


}
